<template>
	<view class="wrap savepadding">
		<!-- 加载中 -->
		<u-tabbar v-if="loading" activeColor="#009CF9" inactiveColor="#B6B6B6" :fixed="true" :placeholder="true"
			:safeAreaInsetBottom="true">
			<u-tabbar-item text="loading...">
				<u-loading-icon slot="active-icon"></u-loading-icon>
				<u-loading-icon slot="inactive-icon"></u-loading-icon>
			</u-tabbar-item>
		</u-tabbar>
		<!-- 加载完成 -->
		<u-tabbar v-else activeColor="#009CF9" :key="orderConfValue" inactiveColor="#B6B6B6" :value="tab" :fixed="true"
			:placeholder="true" :safeAreaInsetBottom="true">
			<template v-for="(item,index) in tabs">
				<u-tabbar-item :text="item.text" :key="index" @click="onClick(item.link)">
					<image style="width:39upx;height:37upx" slot="active-icon" :src="item.activeIcon"></image>
					<image style="width:39upx;height:37upx" slot="inactive-icon" :src="item.inactiveIcon"></image>
				</u-tabbar-item>
			</template>
		</u-tabbar>
	</view>
</template>

<script>
	// import * as orderApi from '@/common/apis/order-api';

	export default {
		props: {
			tab: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				loading: true,
				orderConfValue: 0,
				list: [
					{
						text: '首页',
						link: '/pages/home/home',
						activeIcon: '/static/tabBar/tabBar_home_selected.png',
						inactiveIcon: '/static/tabBar/tabBar_home_default.png',
					},
					// {
					// 	text: '活动专区',
					// 	link: '/pages/activity/activity',
					// 	activeIcon: '/static/tabBar/tabBar_home_selected.png',
					// 	inactiveIcon: '/static/tabBar/tabBar_home_default.png',
					// },
					{
						text: '发现',
						link: '/pages/coupon/coupon',
						activeIcon: '/static/tabBar/tabBar_service_selected.png',
						inactiveIcon: '/static/tabBar/tabBar_service_default.png',
					},
					
					{
						text: '我的',
						link: '/pages/mine/mine',
						activeIcon: '/static/tabBar/tabBar_mine_selected.png',
						inactiveIcon: '/static/tabBar/tabBar_mine_default.png',
					},
				],
			};
		},
		computed: {
			tabs() {
				if (this.loading) {
					return [];
				}
				// if (this.orderConfValue == 0) {
				//     return [
				//         this.list[0],
				//         {},
				//         this.list[2],
				//     ];
				// }
				return this.list;
			},
		},
		async mounted() {
			// await this.orderConf();
			this.loading = false;
		},
		methods: {
			// async orderConf() {
			//     try {
			//         const result = await orderApi.orderConf();
			//         this.orderConfValue = result;
			//         return result;
			//     } catch (error) {
			//         uni.showToast({ title: error, icon: 'error' });
			//     }
			// },
			onClick(path) {
				// console.log(path);
				uni.switchTab({
					url: path
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.wrap {
		position: relative;
		z-index: 100;
	}
</style>
